// To change this License template, choose Tools / Templates
// and edit Licenses / FanDefaultLicense.txt
//
// History:
//   21.01.2011 jst Creation
//

using sql::Col

**
** DataColumn
**
class DataColumn : Column
{
  Type type
  Constraint[]? constraints := null
  
  new make (Str name, Type type, |This|? closure:=null) : super(name) {
    this.type = type
    if (closure!=null) closure(this)
  }

  @Operator
  This add(Constraint constraint) {
    constraints.add(constraint)
  }
  
  Str? checkValue (Obj value) {
    if (constraints==null) return null
    Str? result := constraints.eachWhile |constraint| {
      constraint.check(value)
    }
    return result
  }
  
}